package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GFwdUserinfo;
import com.gzck.gzck_verson2.pojo.GFwdUserprivilege;
import com.gzck.gzck_verson2.service.IGFwdUserprivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户权限表 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-fwd-userprivilege")
public class GFwdUserprivilegeController {

    @Autowired
    private IGFwdUserprivilegeService userprivilegeService;

    // 添加用户权限信息
    @PostMapping("/add")
    public boolean addUserprivilege(@RequestBody GFwdUserprivilege userprivilege) {
        return userprivilegeService.save(userprivilege);
    }

    // 删除用户权限信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteUserprivilege(@PathVariable Long id) {
        return userprivilegeService.removeById(id);
    }

    // 更新用户权限信息
    @PutMapping("/update")
    public boolean updateUserprivilege(@RequestBody GFwdUserprivilege userprivilege) {
        return userprivilegeService.updateById(userprivilege);
    }

    // 查询单个用户权限信息
    @GetMapping("/{id}")
    public GFwdUserprivilege getUserprivilege(@PathVariable Long id) {
        return userprivilegeService.getById(id);
    }

    // 查询所有用户权限信息
    @GetMapping("/all")
    public List<GFwdUserprivilege> getAllUserprivileges() {
        return userprivilegeService.list();
    }
}
